home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kopete / kopetecontactproperty.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.8 KB  |  196 lines

  1. /*
  2.     kopetecontactproperty.h
  3.  
  4.     Kopete::Contact Property class
  5.  
  6.     Copyright (c) 2004    by Stefan Gehn <metz AT gehn.net>
  7.     Kopete    (c) 2004    by the Kopete developers <kopete-devel@kde.org>
  8.  
  9.     *************************************************************************
  10.     *                                                                       *
  11.     * This library is free software; you can redistribute it and/or         *
  12.     * modify it under the terms of the GNU Lesser General Public            *
  13.     * License as published by the Free Software Foundation; either          *
  14.     * version 2 of the License, or (at your option) any later version.      *
  15.     *                                                                       *
  16.     *************************************************************************
  17. */
  18.  
  19. #ifndef _KOPETECONTACTPROPERTY_H_
  20. #define _KOPETECONTACTPROPERTY_H_
  21.  
  22. #include <qvariant.h>
  23.  
  24. #include "kopete_export.h"
  25.  
  26. namespace Kopete
  27. {
  28.  
  29. struct ContactPropertyTmplPrivate;
  30.  
  31. /**
  32.  * @author Stefan Gehn <metz AT gehn.net>
  33.  *
  34.  * The template class for registering properties in Kopete
  35.  * You need to use this if you want to set properties for a
  36.  * Kopete::Contact
  37.  **/
  38. class KOPETE_EXPORT ContactPropertyTmpl
  39. {
  40.     public:
  41.         /**
  42.          * Constructor only used for empty ContactPropertyTmpl objects
  43.          *
  44.          * Note: Only useful for the null object
  45.          **/
  46.         ContactPropertyTmpl();
  47.  
  48.         /**
  49.          * Constructor
  50.          * @param key internal unique key for this template
  51.          * @param label a label to show for properties based on this template
  52.          * @param icon name of the icon to show for properties based on this template
  53.          * @param persistent if true, properties based on this template will be
  54.          *  saved to the contactlist.
  55.          * @param richText Indicate that this property should be able to handle rich text
  56.          * @param privateProp if true, properties based on this template won't be
  57.          *  visible to the user
  58.          **/
  59.         ContactPropertyTmpl( const QString &key,
  60.             const QString &label,
  61.             const QString &icon = QString::null,
  62.             bool persistent = false,
  63.             bool richText = false,
  64.             bool privateProp = false );
  65.  
  66.         /**
  67.          * Copy constructor
  68.          **/
  69.         ContactPropertyTmpl(const ContactPropertyTmpl &other);
  70.  
  71.         /** Destructor */
  72.         ~ContactPropertyTmpl();
  73.  
  74.         ContactPropertyTmpl &operator=(const ContactPropertyTmpl &other);
  75.  
  76.         bool operator==(const ContactPropertyTmpl &other) const;
  77.         bool operator!=(const ContactPropertyTmpl &other) const;
  78.  
  79.         /**
  80.          * Getter for the unique key. Properties based on this template will be
  81.          * stored with this key
  82.          **/
  83.         const QString &key() const;
  84.  
  85.         /**
  86.          * Getter for i18ned label
  87.          **/
  88.         const QString &label() const;
  89.  
  90.         /**
  91.          * Getter for icon to show aside or instead of @p label()
  92.          **/
  93.         const QString &icon() const;
  94.  
  95.         /**
  96.          * Returns true if properties based on this template should
  97.          * be saved across Kopete sessions, false otherwise.
  98.          **/
  99.         bool persistent() const;
  100.  
  101.         /**
  102.          * Returns true if properties based on this template are HTML formatted
  103.          **/
  104.         bool isRichText() const;
  105.  
  106.         /**
  107.          * Returns true if properties based on this template are invisible to the user
  108.          **/
  109.         bool isPrivate() const;
  110.  
  111.         /**
  112.          * An empty template, check for it using isNull()
  113.          */
  114.         static ContactPropertyTmpl null;
  115.  
  116.         /**
  117.          * Returns true if this object is an empty template
  118.          **/
  119.         bool isNull() const;
  120.  
  121.         /**
  122.          * A Map of QString and ContactPropertyTmpl objects, based on QMap
  123.          **/
  124.         typedef QMap<QString, ContactPropertyTmpl>  Map;
  125.  
  126.     private:
  127.         ContactPropertyTmplPrivate *d;
  128. };
  129.  
  130.  
  131. /**
  132.  * @author Stefan Gehn <metz AT gehn.net>
  133.  *
  134.  * A data container for whatever information Kopete or any of its
  135.  * plugins want to store for a Kopete::Contact
  136.  **/
  137. class KOPETE_EXPORT ContactProperty
  138. {
  139.     // TODO: Add d-pointer !
  140.     public:
  141.         /**
  142.          * Constructor only used for empty ContactProperty objects
  143.          *
  144.          * Note: you cannot set a label or value later on!
  145.          **/
  146.         ContactProperty();
  147.  
  148.         /**
  149.          * @param tmpl The contact property template this property is based on
  150.          * @param value The value this Property holds
  151.          **/
  152.         ContactProperty(const ContactPropertyTmpl &tmpl, const QVariant &value);
  153.  
  154.         /** Destructor **/
  155.         ~ContactProperty();
  156.  
  157.         /**
  158.          * Getter for this properties template
  159.          **/
  160.         const ContactPropertyTmpl &tmpl() const;
  161.  
  162.         /**
  163.          * Getter for this properties value
  164.          **/
  165.         const QVariant &value() const;
  166.  
  167.         /**
  168.          * The null, i.e. empty, ContactProperty
  169.          */
  170.         static ContactProperty null;
  171.  
  172.         /**
  173.          * Returns true if this object is an empty Property (i.e. it holds no
  174.          * value), false otherwise.
  175.          **/
  176.         bool isNull() const;
  177.  
  178.         /**
  179.          * Returns true if this property is HTML formatted
  180.          **/
  181.         bool isRichText() const;
  182.  
  183.         /**
  184.          * A map of key,ContactProperty items
  185.          **/
  186.         typedef QMap<QString, ContactProperty> Map;
  187.  
  188.     private:
  189.         QVariant mValue;
  190.         ContactPropertyTmpl mTemplate;
  191. };
  192.  
  193. } // END namespace Kopete
  194.  
  195. #endif //_KOPETECONTACTPROPERTY_H_
  196.